# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>

_name=cbor2
pkgname=python-cbor2
pkgver=5.5.1
pkgrel=1
pkgdesc="Pure Python CBOR (de)serializer with extensive tag support"
arch=(loong64 x86_64)
url="https://github.com/agronholm/cbor2"
license=(MIT)
depends=(
  glibc
  python
)
makedepends=(
  python-build
  python-installer
  python-setuptools-scm
  python-toml
  python-wheel
)
checkdepends=(
  python-hypothesis
  python-pytest
)
source=($_name-$pkgver.tar.gz::$url/archive/refs/tags/$pkgver.tar.gz)
sha512sums=('c4273cd8a8cbbbe2dc035c153224f290d03c937243c68731a5412741543031947e9a2f07fda101ace2aab6d3f5f37bd076a7ba2b7e86d75f7711e10b9eb2013d')
b2sums=('359d8935b0500c3e747382b9bc467cef2583467b8f30830cd0802322a81bdb93b898ce9f3720fd1629bbc5161f82f507535ae57b108797d3bf03817efc40326e')

build() {
  cd $_name-$pkgver
  SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver python -m build -wn
}

check() {
  cd $_name-$pkgver
  export PYTHONPATH="build:${PYTHONPATH}"
  pytest -v -c /dev/null tests
}

package() {
  cd $_name-$pkgver
  python -m installer -d "$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 LICENSE.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
}
